home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / lockpr.arc / LOCKTWO.C < prev    next >
Text File  |  1988-09-01  |  5KB  |  185 lines

  1. /*   ««< Include Files >»»   */
  2. #include "xql.h"
  3. #include "stdio.h"
  4.  
  5.  
  6.  
  7. /*  ««< Function Definitions >»»  */
  8. void     init_string    (int string_length, char *string);
  9.  
  10.  
  11.  
  12. /*  ««< Symbolic Constants >»»  */
  13. #define  CLIENT_NO            long
  14. #define  COMPANY_NAME_LENGTH    76
  15. #define  LAST_NAME_LENGTH       21
  16. #define  FIRST_NAME_LENGTH      23
  17. #define  MIDDLE_INIT_LENGTH      3
  18. #define  ADDRESS_LENGTH         41
  19. #define  ZIPCODE_LENGTH         11
  20. #define  LAST_NAME_LENGTH       21
  21. #define  CLIENT_ALPHA_LENGTH     6
  22. #define  CASE_NAME_LENGTH       41
  23. #define  PHONE_NUM_LENGTH       14
  24.  
  25.  
  26.  
  27.  
  28. /*  ««< Enumerated Data Types >»»  */
  29. typedef enum { FETCH_CURRENT, FETCH_FIRST, FETCH_NEXT, FETCH_PREVIOUS, FETCH_LAST, RELEASE = 7, NOWAIT_IMPLICIT = 1024, NOWAIT_EXPLICIT = 4096 } XQL_REC_FETCH_TYPE;
  30. typedef enum { CHARACTER, INTEGER, FLOAT, DATE, TIME, DECIMAL, MONEY, LOGICAL, NUMERIC, BFLOAT, LSTRING, ZSTRING, NOTE, LVAR } XQL_DATA_TYPES;
  31. typedef enum { FALSE, TRUE } BOOLEAN;
  32.  
  33.  
  34. /*  ««< Structures >»»  */
  35. typedef struct {
  36.                 char       company_name[COMPANY_NAME_LENGTH],
  37.                            last_name[LAST_NAME_LENGTH],
  38.                            first_name[FIRST_NAME_LENGTH],
  39.                            middle_initial[MIDDLE_INIT_LENGTH],
  40.                            addr_one[ADDRESS_LENGTH],
  41.                            addr_two[ADDRESS_LENGTH],
  42.                            addr_three[ADDRESS_LENGTH],
  43.                            city[ADDRESS_LENGTH],
  44.                            state[ADDRESS_LENGTH];
  45.                 char       zipcode[ZIPCODE_LENGTH];
  46.                 int        primary_atty;
  47.                 char       client_alpha[CLIENT_ALPHA_LENGTH];
  48.                 CLIENT_NO  client_number;
  49.                 char       phone_num[PHONE_NUM_LENGTH];
  50.         } CLIENT_RECORD;
  51.  
  52.  
  53. /*  ««< Global Variables >»»  */
  54. int SQLCODE;
  55. char xql_command[] = {"Select * from clients WHERE last_name >= \"Pulley\" AND last_name <= \"Pulley\" "};
  56.  
  57.  
  58.  
  59.  
  60. main ( )
  61. {
  62.  
  63.    CLIENT_RECORD client_record;
  64.    char          xql_fetchbuf[800];
  65.    int           xql_status,
  66.                  xql_cursor,
  67.                  xql_buflen,
  68.                  xql_fetch_flag,
  69.                  xql_fetch_spacing,
  70.                  xql_command_strlen,
  71.                  loop_count,
  72.                  lcv;
  73.    long          xql_fetch_count;
  74.  
  75.  
  76.    /* Login to XQL */
  77.    xql_status = XQLLogin ("", "", "", "", "", 0);
  78.  
  79.     /* Request Cursor */
  80.     xql_status = XQLCursor (&xql_cursor);
  81.     if (xql_status) {
  82.          printf (" Error : %d  XQL Cursor\n\n", xql_status);
  83.     }
  84.  
  85.  
  86.     /* Get String Lengh */
  87.     xql_command_strlen = strlen (xql_command);
  88.  
  89.  
  90.     /* Compile XQL Command */
  91.     xql_status = XQLCompile (xql_cursor, &xql_command_strlen, xql_command);
  92.     if (xql_status) {
  93.          printf (" Error : %d  XQL Compile\n\n", xql_status);
  94.     }
  95.  
  96.  
  97.     /* Init Variables */
  98.     xql_buflen = 800;
  99.     xql_fetch_count = 1;
  100.     xql_fetch_flag  = 2;
  101.     xql_fetch_spacing  = 1;
  102.     init_string (800, xql_fetchbuf);
  103.  
  104.  
  105.     /* Fetch First Record */
  106.     xql_status = XQLFetch (xql_cursor, FETCH_FIRST + NOWAIT_EXPLICIT, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
  107.     if (xql_status) {
  108.          printf (" Error : %d  XQL Fetch\n\n", xql_status);
  109.          XQLLogout ( );
  110.          exit ();
  111.     }
  112.     else {
  113.          printf ("Fetched Record No :  1\n");
  114.     }
  115.  
  116.  
  117.  
  118.     /* Release Record */
  119.     xql_status = XQLFetch (xql_cursor, FETCH_CURRENT + RELEASE, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
  120.     if (xql_status) {
  121.          printf (" Error : %d  XQL Release\n\n", xql_status);
  122.          XQLLogout ( );
  123.          exit ();
  124.     }
  125.     else {
  126.          printf ("Released Record No :  1\n\n" );
  127.     }
  128.  
  129.  
  130.  
  131.     /* Init Loop Count & Loop Control variable */
  132.     loop_count = 1;
  133.     lcv = TRUE;
  134.     
  135.     while (lcv) {
  136.  
  137.          /* Init Variables */
  138.          xql_buflen = 800;
  139.          xql_fetch_count = 1;
  140.          xql_fetch_flag  = 2;
  141.          xql_fetch_spacing  = 1;
  142.  
  143.          
  144.          printf ("Loop Number : %d\n", loop_count);
  145.  
  146.          /* Fetch Next Record */
  147.          xql_status = XQLFetch (xql_cursor, FETCH_NEXT + NOWAIT_EXPLICIT, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
  148.          if (xql_status) {
  149.               printf (" Error : %d  XQL Fetch\n\n", xql_status);
  150.               lcv = FALSE;
  151.          }
  152.          else {
  153.               printf ("Fetched Record No :  %d\n", loop_count);
  154.          }
  155.  
  156.  
  157.  
  158.          /* Release Record */
  159.          xql_status = XQLFetch (xql_cursor, FETCH_CURRENT + RELEASE, &xql_buflen, xql_fetchbuf, &xql_fetch_count, xql_fetch_flag, xql_fetch_spacing);
  160.          if (xql_status) {
  161.               printf (" Error : %d  XQL Release\n\n", xql_status);
  162.               lcv = FALSE;
  163.          }
  164.          else {
  165.               printf ("Released Record No :  %d\n\n\n", loop_count);
  166.          }
  167.  
  168.          /* Increment Loop Count */
  169.          loop_count++;
  170.     } /* end while */
  171.  
  172.  
  173. } /* END MAIN */
  174.  
  175.  
  176.  
  177. void  init_string (int string_length, char *string)
  178. {
  179.     int  index;
  180.  
  181.     for (index = 0; index < string_length; index++)
  182.          string[index] = NULL;
  183.  
  184. }
  185.